package jdbc;

import jdbc.utill.DButil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/*
执行dql语句
 */
public class JdbcDemo06 {
    public static void main(String[] args) throws Exception {
        Connection connection= DButil.getConnection();
        Statement statement=connection.createStatement();
        String sql="select name ,age from student where age =8 and name like '%苗%';";
        ResultSet resultSet=statement.executeQuery(sql);
        while(resultSet.next()){
             String name = resultSet.getString("name");
             int age = resultSet.getInt("age");
            System.out.println("name:"+name+",age:"+age);
        }
        DButil.close(connection);
    }
}
